#pragma once




//------------------------------------------------------------------------------
/**
	Convert ticks to seconds.
*/
inline Time
TicksToSeconds(Tick ticks)
{
	return ticks * 0.001;
}

//------------------------------------------------------------------------------
/**
	Convert seconds to ticks
*/
inline Tick
SecondsToTicks(Time t)
{
	// perform correct rounding
	return Tick((t * 1000.0) + 0.5);
}

//------------------------------------------------------------------------------

class WinTimer
{
public:
	/// constructor
	WinTimer();
	/// start/continue the timer
	void Start();
	/// stop the timer
	void Stop();
	/// reset the timer
	void Reset();
	/// return true if currently running
	bool Running() const;
	/// get current time in seconds
	Time GetTime() const;
	/// get current time in ticks
	Tick GetTicks() const;

private:
	/// return internal time as 64 bit integer
	__int64 InternalTime() const;

	bool running;
	__int64 diffTime;  // accumulated time when the timer was not running
	__int64 stopTime;  // when was the timer last stopped?
};


////////////////////////////////////////////////////////////////////////////////////////////////


